package com.lhf.fvssystem.security;

import com.lhf.fvscommon.entity.SysUser;
import com.lhf.fvssystem.dao.SysUserDao;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p></p>
 *
 * @author lhf
 * @since 2020/10/26 14:52
 */
@Service("userdetails")
public class UserDetailsServiceImpl implements UserDetailsService {

    @Resource
    private SysUserDao sysUserDao;

    @Override
    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
        SysUserDetails sysUser = sysUserDao.selectRolesByUser(s);
        if (sysUser == null) {
            throw new UsernameNotFoundException("用户未找到");
        }
        return sysUser;
    }
}
